package com.zhuangfei.hos_timetableview;

import com.zhuangfei.hos_timetableview.ability.AttrAbility;
import com.zhuangfei.hos_timetableview.ability.BaseFuncAbility;
import com.zhuangfei.hos_timetableview.ability.ColorPoolAbility;
import com.zhuangfei.hos_timetableview.ability.CustomWidthAbility;
import com.zhuangfei.hos_timetableview.ability.DateAbility;
import com.zhuangfei.hos_timetableview.ability.DateDelayAbility;
import com.zhuangfei.hos_timetableview.ability.ElasticAbility;
import com.zhuangfei.hos_timetableview.ability.ExtrasAbility;
import com.zhuangfei.hos_timetableview.ability.FlaglayoutAbility;
import com.zhuangfei.hos_timetableview.ability.ItemStyleAbility;
import com.zhuangfei.hos_timetableview.ability.LocalConfigAbility;
import com.zhuangfei.hos_timetableview.ability.NonViewAbility;
import com.zhuangfei.hos_timetableview.ability.SimpleAbility;
import com.zhuangfei.hos_timetableview.ability.SlideAbility;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Component;

public class MainAbility extends Ability implements Component.ClickedListener {

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_main);
        initView();
    }

    private void initView() {
        findComponentById(ResourceTable.Id_id_btn0).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn1).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn2).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn3).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn4).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn5).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn6).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn7).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn8).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn9).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn10).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn11).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn12).setClickedListener(this);
        findComponentById(ResourceTable.Id_id_btn13).setClickedListener(this);
    }

    public void toTarget(Class cla) {
        Intent secondIntent = new Intent();
        Operation operation = new Intent.OperationBuilder()
                .withBundleName(getBundleName())
                .withAbilityName(cla.getName())
                .build();
        secondIntent.setOperation(operation);
        startAbility(secondIntent);
    }

    @Override
    public void onClick(Component component) {
        switch (component.getId()) {
            case ResourceTable.Id_id_btn0:
                toTarget(SimpleAbility.class);
                break;
            case ResourceTable.Id_id_btn1:
                toTarget(BaseFuncAbility.class);
                break;
            case ResourceTable.Id_id_btn2:
                toTarget(AttrAbility.class);
                break;
            case ResourceTable.Id_id_btn3:
                toTarget(ColorPoolAbility.class);
                break;
            case ResourceTable.Id_id_btn4:
                toTarget(ItemStyleAbility.class);
                break;
            case ResourceTable.Id_id_btn5:
                toTarget(CustomWidthAbility.class);
                break;
            case ResourceTable.Id_id_btn6:
                toTarget(ElasticAbility.class);
                break;
            case ResourceTable.Id_id_btn7:
                toTarget(SlideAbility.class);
                break;
            case ResourceTable.Id_id_btn8:
                toTarget(DateAbility.class);
                break;
            case ResourceTable.Id_id_btn9:
                toTarget(NonViewAbility.class);
                break;
            case ResourceTable.Id_id_btn10:
                toTarget(ExtrasAbility.class);
                break;
            case ResourceTable.Id_id_btn11:
                toTarget(FlaglayoutAbility.class);
                break;
            case ResourceTable.Id_id_btn12:
                toTarget(DateDelayAbility.class);
                break;
            case ResourceTable.Id_id_btn13:
                toTarget(LocalConfigAbility.class);
                break;
            default:
                break;
        }
    }

}
